import { _decorator, Vec2 } from 'cc';
import { RowFallClear_GameStorage } from './RowFallClear_GameStorage';

export class RowFallClear_GameData {
    static row: number = 10// 12; // 行数
    static col: number = 8; // 列数
    static size: number = 90; // 方块的尺寸
    // static slideSize: number = 50; // 滑动距离
    static W: number = RowFallClear_GameData.size * RowFallClear_GameData.col;
    static H: number = RowFallClear_GameData.size * RowFallClear_GameData.row;

    //    /** 是否可以操作 */
    static IsCanOperate: boolean = true;

    //    /** 卡牌 */
    static arrCards: any[][] = [];
    //    /** 地形格子 XXL_Grid */
    static arrGrids: any[][] = [];
    //    /** StartPos */
    static StartPos: Vec2;
    //    /** CurrentPos */
    static CurrentPos: Vec2;
    //    /** IsMouseDown  */
    static IsMouseDown: boolean = false;

    static hasNewLine: boolean = false;
    //    // 连消数量
    static ContinuousEliminationNumber: number = 0;
    //    /** 最少行数 */
    static MinRowNumber: number = 2;
    static high_score: number = 0;
    static gameMode = 0; // 0普通模式 1冒险模式
    static desertGameUseTime: number = 0;

    static InitData() {
        // RowFallClear_GameData.arrGrids = [];
        // RowFallClear_GameData.arrCards = [];
    }

    static GetScore() {
        return RowFallClear_GameStorage.data.mode_1.score;
    }
    static SetScore(value) {
        RowFallClear_GameStorage.data.mode_1.score = value;
        RowFallClear_GameStorage.saveData();
    }

    static GetLevel() {
        return 0;
        // return RowFallClear_GameStorage.data.GameData.level;
    }
    // static SetLevel(value) {
    //     RowFallClear_GameStorage.data.GameData.level = value;
    //     RowFallClear_GameStorage.saveData();
    // }
    //    // 刷新后，但是行数不满足min(等级+1，6），则通过保底刷新的方式，将方块行数补全到指定行数。
    static GetMinRowNumber() {
        let number = RowFallClear_GameData.GetLevel() + 1 + 1;
        RowFallClear_GameData.MinRowNumber = number < 6 ? number : 6;
        return RowFallClear_GameData.MinRowNumber;
    }
    //    /** 是否死亡 */
    static IsDead() {
        // if (RowFallClear_GameData.arrCardGroups[TurkishTetris_GameConfig.row - 1].length > 0) {
        //     // if (GameData.arrCardGroups[3].length > 0) {
        //     return true;
        // }

        return false;
    }

    static ClearData() {
        RowFallClear_GameData.arrGrids = [];
        RowFallClear_GameData.arrCards = [];

        RowFallClear_GameData.ContinuousEliminationNumber = 0;
        RowFallClear_GameData.MinRowNumber = 2;

        // RowFallClear_GameData.curScore = 0;
        RowFallClear_GameData.SetScore(0);

        RowFallClear_GameData.StartPos = null;
        RowFallClear_GameData.CurrentPos = null;
        RowFallClear_GameData.IsMouseDown = false;

        RowFallClear_GameData.IsCanOperate = true;

        RowFallClear_GameData.desertGameUseTime = 0;
    }
}

window["RowFallClear_GameData"] = RowFallClear_GameData;